package com.wgchao.pharmacymg.domain.entity;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

import com.wgchao.pharmacymg.Infrastructure.utils.ChineseCharacterUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.util.StringUtils;

/**
 * @作者  wgchao
 * @时间 2019-11-18 
 * @用途 药品信息
 */

@AllArgsConstructor
@NoArgsConstructor
@Data
@Entity
@Table ( name ="ph_drug_info" )
public class PhDrugInfoDO  implements Serializable {

	private static final long serialVersionUID =  9174721916195597621L;

	/**
	 * 药品编码-主键
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
   	@Column(name = "drug_id" )
	private Long drugId;

	/**
	 * 药品通用名称
	 */
   	@Column(name = "drug_common_name" )
	private String drugCommonName;

	/**
	 * 药品商品名
	 */
   	@Column(name = "drug_shop_name" )
	private String drugShopName;

	/**
	 * 规格
	 */
   	@Column(name = "spec" )
	private String spec;

	/**
	 * 单位
	 */
   	@Column(name = "unit" )
	private String unit;

	/**
	 * 生产厂家
	 */
   	@Column(name = "manufacturer_id" )
	private Long manufacturerId;

	/**
	 * 条形码
	 */
   	@Column(name = "txm" )
	private String txm;

	/**
	 * 批准文号
	 */
   	@Column(name = "approval_number" )
	private String approvalNumber;

	/**
	 * 有效期
	 */
   	@Column(name = "validity" )
	private String validity;

	/**
	 * 国药准字
	 */
   	@Column(name = "gyzz" )
	private String gyzz;

	/**
	 * 单价
	 */
   	@Column(name = "uprice" )
	private Double uprice;

	/**
	 * 助记码
	 */
   	@Column(name = "zjm" )
	private String zjm;

	/**
	 * 机构编号
	 */
   	@Column(name = "agency_code" )
	private String agencyCode;

	/**
	 * 删除标志
	 */
	@Column(name = "del" )
	private boolean del;

	/**
	 * 删除时间
	 */
	@Column(name = "del_time" )
	private Date delTime;

	public void delete(){
		this.del = true;
		this.delTime = new Date();
	}

	/**
	 * 创建时 没有助记码 默认首字母
	 */
	public void create(){
		this.del = false;
		if(StringUtils.isEmpty(this.zjm)){
			this.zjm = ChineseCharacterUtil.getLowerCase(this.drugCommonName, false);
		}
	}

}
